package com.os.mybatisplus_1;

import com.os.domain.User;
import com.os.mapper.UserMapper;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@SpringBootApplication
@MapperScan("com.os.mapper")
@Controller
public class Mybatisplus1Application {

    @Autowired
    private UserMapper userMapper;

    @RequestMapping("/testSelect")
    @ResponseBody
    public List<User> testSelect(){
        List<User> userList = userMapper.selectList(null);
        return userList;
    }

    @RequestMapping("/testAdd")
    @ResponseBody
    public int testAdd(){
        User user = new User();
        user.setName("宋传磊");
        int iNum = userMapper.insert(user);
        return iNum;
    }

    public static void main(String[] args) {
        SpringApplication.run(Mybatisplus1Application.class, args);
    }

}
